package com.usian.admin.controller;

import com.usian.common.aliyun.GreeTextScan;
import com.usian.common.aliyun.GreenImageScan;
import com.usian.common.fastdfs.FastDFSClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/aliyun")
public class AliyunController {

    @Autowired
    private GreeTextScan greeTextScan;

    @Autowired
    private GreenImageScan greenImageScan;

    @Autowired
    private FastDFSClient fastDFSClient;

    @GetMapping("/Text")
    public void text() throws Exception {
        Map map = greeTextScan.greeTextScan("我是好人,不贩卖冰毒");
        System.out.println(map);
    }

    @GetMapping("/Text2")
    public void text2() throws Exception {
        Map map = greeTextScan.greeTextScan("我是好人");
        System.out.println(map);
    }

    @GetMapping("/img")
    public void img() throws Exception {
        byte[] image1 = fastDFSClient.download("group1", "M00/00/00/wKg6imK2_KSAAaSoAAwVPTBA8Ww390.gif");
        List<byte[]> images = new ArrayList<>();
        images.add(image1);
        Map map = greenImageScan.imageScan(images);
        System.out.println(map);
    }
}
